package com.lmx.persistence.service;

import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.lmx.common.util.CommonUtil;
import com.lmx.persistence.service.common.BaseCrudServiceImpl;
import com.lmx.repoDomain.tmodel.CustomerFoodPlan;

/**
 * 老人用餐
 *
 * @author ytche
 * @date 2017年8月30日
 *
 */
@Service
public class CustomerFoodPlanServiceImpl extends
		BaseCrudServiceImpl<CustomerFoodPlan> implements
		CustomerFoodPlanService {

	@Override
	public List<CustomerFoodPlan> findDayPlan(Date date, Long tenantId) {
		Integer startTime = CommonUtil.getDayBegin(date);
		Integer endTime = startTime + 3600 * 24;
		String hql = "from CustomerFoodPlan as plan where plan.delStatus=0"
				+ " and plan.diningDate>= :startTime and plan.diningDate < :endTime ";
		return super.em.createQuery(hql).setParameter("startTime", startTime)
				.setParameter("endTime", endTime).getResultList();
	}
}
